<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
		//假设这些数据，需要用接口来获取
		let uid = 1
		let users = [
			{
				uid: 1,
				name: '张三'
			},
			{
				uid: 2,
				name: '李四'
			},
			{
				uid: 3,
				name: '王五'
			}
		]
		
		//模拟promise异步请求
		new Promise((resolve, reject)=>{
			//获取到uid
				resolve(uid)
		})
		.then(value=>{
			console.log('请求到了uid：' + value)
			//用uid获取name
			let user = users.reduce((last, cur)=>{
				if(cur.uid === value){
					last.push(cur)
				}
				return last
			},[])
			
			//向下传递
			return new Promise((resolve, reject)=>{
				resolve(user)
			})
		}, err=>{})
		.then(value=>{
			console.log('用uid请求到了user：', value)
		}, err=>{})
		
	</script>
</html>
